package spring.dao;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.smallframework.spring.DaoTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import sf.ext.gen.GenConfig;
import sf.ext.gen.MapperCodeGen;
import sf.ext.gen.MapperImplCodeGen;
import spring.BaseServiceTest;

import java.io.File;
@Slf4j
public class GenCodeService extends BaseServiceTest {
    @Autowired
    private DaoTemplate dt;
    @Test
    public void testGenCodes() {
        dt.execute(c->{
            log.info("dirive url:"+c.getMetaData().getURL());
            return null;
        });
        String mapperPkg = "org.linlinjava.litemall.db.sorm.dao";
        String mapperImplPkg = "org.linlinjava.litemall.db.sorm.dao.impl";
        String domainPkg = "org.linlinjava.litemall.db.sorm.domain";
        GenConfig genConfig = new GenConfig();
        MapperCodeGen mapperCodeGen = new MapperCodeGen(mapperPkg);
        mapperCodeGen.setOnlyMapper(false);
        genConfig.codeGens.add(mapperCodeGen);
        MapperImplCodeGen mapperImplCodeGen = new MapperImplCodeGen(mapperImplPkg);
        mapperImplCodeGen.setMapperPkg(mapperPkg);
        genConfig.codeGens.add(mapperImplCodeGen);

        dt.genPojoCodes(domainPkg, System.getProperty("user.dir") + File.separator + "com/wdgame", genConfig);
    }
}
